<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			function cal(type){
				var num1 = document.getElementById("input1").value;
				var num2 = document.getElementById("input2").value;
				switch(type){
					case '+':
					var calresult = parseInt(num1) + parseInt(num2);
					break;
					case '-':
					var calresult = parseInt(num1) - parseInt(num2);
					break;
					case '*':
					var calresult = parseInt(num1) * parseInt(num2);
					break;
					case '/':
					var calresult = parseInt(num1) / parseInt(num2);
					break;
				}
				var result = document.getElementById("result");
				result.value = calresult;
			}
		</script>
	</head>
	<body>
		<table>
			<tr>
				<td>
					<img src="QQ截图20180817112525.png" width="60px" height="60px"/>
				</td>
				<td colspan="3">购物简易计算器</td>
			</tr>
			<tr>
				<td>第一个数</td>
				<td colspan="3">
					<input type="text" id="input1" />
				</td>
			</tr>
			<tr>
				<td>第二个数</td>
				<td colspan="3">
					<input type="text" id="input2" />
				</td>
			<tr>
				<td>
					<input type="button" onclick="cal('+')" value=" + " />
				</td>
				<td>
					<input type="button" onclick="cal('-')" value=" - " />
				</td>
				<td>
					<input type="button" onclick="cal('*')" value=" * " />
				</td>
				<td>
					<input type="button" onclick="cal('/')" value=" / " />
				</td>
			</tr>
			<tr>
				<td>计算结果</td>
				<td colspan="3"><input type="text" id="result" /> </td>
			</tr>
		</table>
	</body>
</html>
